import time

from config.config import Base
from selenium import webdriver
from selenium.webdriver.common.by import By


class Page(Base):
    # 输入软件测试自动化
    shuru_loc = (By.ID, 'query')
    def shuru(self):
        self.send_keys(self.shuru_loc, '软件测试自动化')
    # 点击按钮
    anniu_loc = (By.XPATH, '/html/body/div[1]/div[2]/div[4]/form/span[2]/input')
    def anniu(self):
        self.click(self.anniu_loc)
    # 标题1
    bt1_loc=(By.XPATH,'/html/body/div[3]/div[2]/div[1]/div[3]/div')
    def bt1(self):
        return self.find_elements(self.bt1_loc)
    # 翻页
    fy_loc=(By.XPATH,'/html/body/div[3]/div[4]/div/a[1]')
    def fy(self):
        self.click(self.fy_loc)
    # 标题2
    bt2_loc=(By.XPATH,'/html/body/div[3]/div[2]/div[1]/div[2]/div')
    def bt2(self):
        return self.find_elements(self.bt2_loc)




    def test_01_ss(self):
        self.open_url('https://www.sogou.com/')
        # assert '软件测试自动化' in self.open_url('https://www.sogou.com/')
        # # 隐式等待
        # self.driver.implicitly_wait()
        self.shuru()
        time.sleep(3)
        self.anniu()
        # 隐式等待
        # self.driver.implicitly_wait()
        time.sleep(3)
        self.bt1()
        time.sleep(2)
        aa=self.bt1()
        for i in aa:
            print(i.text)
        # self.bt1()
        # time.sleep(3)
        # assert '软件测试' in self.bt1()
        self.fy()
        time.sleep(3)
        print('----------------------------------第二页--------------------------------------')
        aa = self.bt2()
        for i in aa:
            print(i.text)



        # self.bt2()
        # assert '软件测试' in self.bt2()
        # time.sleep(2)


























